import filter from '../../utils/filter.js'
import request from '../../utils/request.js'
import config from '../../utils/config.js'
const app = getApp()

Page({
  data: {
    userInfo: null,
    userType: 0
  },
  onLoad: function (options) {
    this.setData({
      'options': options,
      'userInfo': app.globalData.userInfo
    })
    filter().then(res => {
      const userType = wx.getStorageSync('userType')
      const userId = wx.getStorageSync('userId')
      this.setData({
        userType: userType ? userType : 0,
        userId: userId ? userId : 0
      })
    }).catch(err => {
      wx.reLaunch({
        url: '/pages/login/login',
      })
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
  //   const openid = wx.getStorageSync('openid')
  //   return {
  //     title: '智能急救培训',
  //     path: '/pages/startup/startup?referrerId=' + (openid || '')
  //   }
  // },

  bindLink(e) {
    if (!e.currentTarget.dataset.url) {
      return false;
    }
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },

  getUserProfile() {

  },

  bindQuit() {
    const openId = wx.getStorageSync('openid')
    wx.clearStorageSync()
    wx.setStorageSync('openid', openId)
    wx.reLaunch({
      url: '/pages/login/login',
    })
  },
})